<template>
	<view class="p30">
		<view class="f40 title">{{ detail.title }}</view>
		<view class="mt20 f28 d-s-c">
			<view class="orange">{{detail.address}}福兴禅寺</view>
			<view class="time gray9 ml20">{{ detail.updatetime }}</view>
			<view class="ml20 gray9">{{ detail.city }}</view>
		</view>
		<view class="d-s-c f28 orange mt20">
			<view class="d-s-c mr20">
				<u-icon size="20" name="server-fill" color="#ff8a00"></u-icon>
				<text class="ml5">{{ detail.view }}人</text>
			</view>
			<view class="d-s-c mr20" @click="setZan">
				<u-icon size="20" :name="detail.is_zan?'thumb-up-fill':'thumb-up'" color="#ff8a00"></u-icon>
				<text class="ml5">{{ detail.zan }}</text>
			</view>
			<view class="d-s-c" @click="setFav">
				<u-icon size="20" :name="detail.is_fav ? 'star-fill' : 'star'" color="#ff8a00"></u-icon>
				<text class="ml5">星标</text>
			</view>
		</view>
		<view class="detail mt60" v-html="detail.content"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				detail: {},
				id: 0
			};
		},
		onLoad({ id }) {
			this.id = id
			this.getDetail();
		},
		methods: {
			async setFav() {
				const res = await this.$request({
					url: this.$api.setFav,
					data: {
						id: this.id,
					},
				});
				if (res.code == 1) {
					this.getDetail()
				}
			},
			async setZan() {
				const res = await this.$request({
					url: this.$api.setZan,
					data: {
						id: this.id,
					},
				});
				if (res.code == 1) {
					this.getDetail()
				}
			},
			async getDetail() {
				const res = await this.$request({
					url: this.$api.pdetail,
					data: {
						id: this.id,
					},
				});
				if (res.code == 1) {
					this.detail = res.data;
				}
			},
			jump(url) {
				uni.navigateTo({
					url,
				});
			},
		},
	};
</script>

<style></style>